// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "Data/MissionStruct.h"
#include "QuestLogWidget.generated.h"

class USingleQuestCategoryWidget;
class UClickedQuestWidget;
class USingleQuestWidget;
UCLASS()
class MISCELLANEOUSPROJECT_API UQuestLogWidget : public UUserWidget
{
	GENERATED_BODY()
public:
	virtual void NativeOnInitialized() override;
	virtual void NativeConstruct() override;
public:
	void ContructWidget(TSubclassOf<USingleQuestWidget> LSingleQuestWidget);
	UFUNCTION()
	void OnClickedToQuests(USingleQuestWidget* QuestWidget);
	UFUNCTION()
	void Stop_Toggle_Track_Timer();
	UFUNCTION()
	void Start_Toggle_Track_Timer();
	UFUNCTION()
	void On_Track_Completed(bool Filled);
	UFUNCTION()
	void Reset_Track_Timer_Handle();
	UFUNCTION()
	void On_Clicked_To_Quest_Category(USingleQuestCategoryWidget* Reference);
	UFUNCTION()
	void On_Hover_To_Quest_Category(USingleQuestCategoryWidget* SelfReference);
	UFUNCTION()
	void On_UnHover_Quest_Category();
	UFUNCTION()
	void On_Hover_To_Single_Quest(USingleQuestWidget* SelfReference);
	UFUNCTION()
	void On_UnHover_Single_Quest();
	void PopulateQuests(EQuestCategoryStatus Category);
	void UpdateHeadline(EQuestCategoryStatus Category);
	void UpdateButtonOpacity(EQuestCategoryStatus Category);
	void CreateQuestList(EQuestCategoryStatus Category);
	void SetAllQuests();
	void GatherQuests(TArray<FMissionMaster> AllQuests);
	void AddQuests(TArray<FMissionMaster> QuestList);
	void UpdateButtonText();
	void UpdateCurrentMission();
	void UpdateSelectedMission();
	bool IsTrackedMission(FMissionMaster MissionInfo);
	void BindClickedWidgetButton();
	bool IsClickedMissionVisible();
	bool IsClickedMissionRepeatable();
	void BindQuestHover();
	void ScrollWidget(bool Up);
	void UpdateHeadlineText(EQuestCategoryStatus Category,bool Animate);
public:
	USingleQuestCategoryWidget* AllCategory;
	USingleQuestCategoryWidget* MainCategory;
	USingleQuestCategoryWidget* SideCategory;
	USingleQuestCategoryWidget* CompletedCategory;
	UClickedQuestWidget* Widget_ClickedQuest;
	UPROPERTY(meta = (BindWidget))
	class UVerticalBox* CategoryList;
	UPROPERTY(meta = (BindWidget))
	class UTextBlock* ListHeadline;
	UPROPERTY(meta = (BindWidget))
	class UScrollBox* QuestList;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ExposeOnSpawn = "true"), Category = "Default")
	TSubclassOf<USingleQuestWidget> SingleQuestWidget;

	TArray<FMissionMaster> AllQuests;
	TArray<FMissionMaster> MainQuests;
	TArray<FMissionMaster> SideQuests;
	TArray<FMissionMaster> CompletedQuests;
	TArray<USingleQuestWidget*> CurrentQuestWidgets;
	USingleQuestWidget* ClickedQuest;
	UUserWidget* HoveredWidget;
	int32 ScrolledIndex;
private:
	bool DoOnce;
};
